# import urllib.request
# import urllib.error
from urllib import request, error  # 对应练习2
import socket

# 异常处理练习1
# try:
#     response = urllib.request.urlopen('http://123.com')
#     print(response.read())
# except urllib.error.URLError as e:
#     print('error')

# 导入模块改变test2
# try:
#     response = request.urlopen('http://123.com')
#     print(response.read())
# except error.URLError as e:
#     print(e.reason)

# test3
# try:
# #     response = request.urlopen('https://httpbin.org/AAA')
# #     print(response.read())
# # except error.HTTPError as e:  # 先打印http错误
# #     print(e.reason, e.code, e.headers, sep='\n')
# # except error.URLError as e:  # 在打印url错误
# #     print(e.reason)
# # else:
# #     print('Query Successfully')

# test4
# try:
#     response = request.urlopen('https://httpbin.org/aaa', timeout=0.1)
#     print(response.read())
# except error.URLError as e:
#     print(type(e.reason))
#     if isinstance(e.reason, socket.timeout):
#         print('Time Out')

print(isinstance(1, str))
print(type(1, '2'))
